package com.ruoyi.statistic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.statistic.domain.WMonthExitWarehouseStat;
import com.ruoyi.statistic.service.IWMonthExitWarehouseStatService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 月出库量Controller
 * 
 * @author wzy
 * @date 2024-09-01 17:26:05
 */
@RestController
@RequestMapping("/statistic/monthexit")
public class WMonthExitWarehouseStatController extends BaseController
{
    @Autowired
    private IWMonthExitWarehouseStatService wMonthExitWarehouseStatService;

    /**
     * 查询月出库量列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthexit:list')")
    @GetMapping("/list")
    public TableDataInfo list(WMonthExitWarehouseStat wMonthExitWarehouseStat)
    {
        startPage();
        List<WMonthExitWarehouseStat> list = wMonthExitWarehouseStatService.selectWMonthExitWarehouseStatList(wMonthExitWarehouseStat);
        return getDataTable(list);
    }

    /**
     * 导出月出库量列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthexit:export')")
    @Log(title = "月出库量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WMonthExitWarehouseStat wMonthExitWarehouseStat)
    {
        List<WMonthExitWarehouseStat> list = wMonthExitWarehouseStatService.selectWMonthExitWarehouseStatList(wMonthExitWarehouseStat);
        ExcelUtil<WMonthExitWarehouseStat> util = new ExcelUtil<WMonthExitWarehouseStat>(WMonthExitWarehouseStat.class);
        util.exportExcel(response, list, "月出库量数据");
    }

    /**
     * 获取月出库量详细信息
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthexit:query')")
    @GetMapping(value = "/{monthExitStatisticId}")
    public AjaxResult getInfo(@PathVariable("monthExitStatisticId") Long monthExitStatisticId)
    {
        return success(wMonthExitWarehouseStatService.selectWMonthExitWarehouseStatByMonthExitStatisticId(monthExitStatisticId));
    }

    /**
     * 新增月出库量
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthexit:add')")
    @Log(title = "月出库量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WMonthExitWarehouseStat wMonthExitWarehouseStat)
    {
        wMonthExitWarehouseStat.setCreateBy(getNickName());
        return toAjax(wMonthExitWarehouseStatService.insertWMonthExitWarehouseStat(wMonthExitWarehouseStat));
    }

    /**
     * 修改月出库量
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthexit:edit')")
    @Log(title = "月出库量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WMonthExitWarehouseStat wMonthExitWarehouseStat)
    {
        wMonthExitWarehouseStat.setUpdateBy(getNickName());
        return toAjax(wMonthExitWarehouseStatService.updateWMonthExitWarehouseStat(wMonthExitWarehouseStat));
    }

    /**
     * 删除月出库量
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthexit:remove')")
    @Log(title = "月出库量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{monthExitStatisticIds}")
    public AjaxResult remove(@PathVariable Long[] monthExitStatisticIds)
    {
        return toAjax(wMonthExitWarehouseStatService.deleteWMonthExitWarehouseStatByMonthExitStatisticIds(monthExitStatisticIds));
    }
}
